<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>TEST</title>
    <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="js/jsencrypt.min.js"></script>
    <style type="text/css">
    </style>
    <script type="text/javascript">

        $(function () {
            $('#btn').click(function () {
                var pwd = $("#pwd").val();
                var encrypt = new JSEncrypt();
                encrypt.setPublicKey("${publicKey}");
                var encrypted = encrypt.encrypt(pwd);
                //console.log(encrypted)
                $.ajax({
                    url:'http://localhost:8080/toLogin',
                    type:'POST', //GET
                    async:true,    //或false,是否异步
                    data:{
                        data:encrypted,type:"login"
                    },
                    timeout:5000,    //超时时间
                    dataType:'text',    //返回的数据格式：json/xml/html/script/jsonp/text

                    success:function(data,textStatus,jqXHR){
                        console.log(data)
                    },
                    error:function(xhr,textStatus){
                        console.log('错误')
                    }
                })
            });
        });

    </script>
</head>
<body>
<form id="form" name="form" action="LoginServlet" method="post">
    <input id="pwd" name="" type="text" value=""/>
    <input id="pwdRsa" name="pwd" type="hidden" value=""/>
    <input id="btn" type="button" value="登录"/>
</form>

</body>
</html>